package com.wengzw.gateway.utils;

import com.wengzw.commonutils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

//使用自己的加密方法对密码进行编码加密验证
@Component
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        return MD5.encrypt(rawPassword.toString());
    }

    //encode(rawPassword)自己加密的，encodedPassword这个是刚才从数据库查出来的密码，也是加密的
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encode(rawPassword).equals(encodedPassword);
    }
}

